POV-Ray : Newsgroups : povray.programming : POV-Ray 3.5 & VS.NET 2003 : POV-Ray 3.5 & VS.NET 2003 Server Time
3 Jul 2024 06:17:37 EDT (-0400)
  POV-Ray 3.5 & VS.NET 2003  
From: Ryan Lamansky
Date: 11 Mar 2004 21:34:43
Message: <405121c3$1@news.povray.org>
Microsoft Visual Studio .NET 2003 is a hot topic in the C++ world.  Lots 
of people have lots to say about.  Unfortunately, one thing being said 
is that POV-Ray 3.5 won't build on it.

With a few modifications, it actually is possible :)  Below are 
step-by-step instructions to take the POV-Ray 3.5 source code from 
www.povray.org and make it build in VS.NET 2003.

Not only does it build, but it actually runs very well (producing a 
smaller, slightly faster .EXE than the released POV-Ray).  It takes 
about an hour to apply the changes (and then it works forever :)

-Install the release version of POV-Ray 3.5 (it registers DLLs you 
need).
-Open VS.NET 2003.
-Choose "Open Project"
-Navigate to The "VC6" folder to find the "Povray.dsw" file.  Open this.
-A warning is presented regarding the conversion of the file.  Choose 
"Yest To All".
-If you see a source control pop-up, click "Ok".  Choose "Work 
Disconnected" from the next pop-up.
-Remove all projects but these: "povray", "jpeg", "libpng", "tiff", 
"zlib".  These projects make up the core of POV-Ray, the most important 
part.
-For fun, try a build at this point.  You get 105 "Build Errors" in your 
task list.  Most of them are duplicates.
-The first error is caused by  Line 87 in "Windows Source\Windows 
Headers\ztimer.h".  Chage <iostream.h> to <iostream>.
-If you decide to build again, it'll take a very long time and report 
1308 errors... Joy!
-Once again, these are mostly duplicates.  In "ztimer.h", comment out 
lines 134 and 174 (they're never actually used).
-Building now goes much more quickly, and yields 59 errors.  That's a 
little better :)
-Open up "POV-Ray Core\Core Headers\optout.h" to comment out line 49.  
You're strongly encouraged to update line 50 to a name.  "POV-Ray 3.5 
built with VS.NET 2003" is a good suggestion :)
-Building now produces 39 errors.
-Open up "Windows Source\Windows Headers\pvengine.h".  Comment out Line 
54, change the definition value on the next line to your name or maybe 
"Visual Studio .NET 2003".
-The next build has 29 errors.
-The next easily-fixed on is in "Windows Source\pvengine.c".  Comment 
out line 109.
-28 errors.  Now it's crunch time.  All of the remaining errors are 
caused by the same situation: mixed parameter types to a function call, 
resulting in VS.NET being unable to decide which one to use.
-The fix for all of these is to up-cast one of the parameters to the 
type of the larger one.  It's slightly different in each case, so I've 
documented the exact lines you have to change to get through this.

(I decided to preserve spaces/tabs, which may cause wrapping in some 
newsreaders)

"POV-Ray Core\image.cpp", line 594
   if(fabs(Image->Colour_Map[x].Filter) > EPSILON) //Before
   if(fabs((float)Image->Colour_Map[x].Filter) > EPSILON) //After
Same file, line 596
   if(fabs(Image->Colour_Map[x].Transmit) > EPSILON) //Before
   if(fabs((float)Image->Colour_Map[x].Transmit) > EPSILON) //After
Same file, line 620
       if (fabs(Image->data.rgb16_lines[y].transm[x]) > EPSILON) 
//Before
       if (fabs((float)Image->data.rgb16_lines[y].transm[x]) > EPSILON) 
//After
Same file, line 636
      if(fabs(Image->data.rgb8_lines[y].transm[x]) > EPSILON) //Before
      if(fabs((float)Image->data.rgb8_lines[y].transm[x]) > EPSILON) 
//After
Same file, line 682
  *v = fmod(y * Image->height, Image->height); //Before
  *v = fmod(y * Image->height, (double)Image->height); //After
Same file, line 969
      *u = fmod(x * Image->width, Image->width); //Before
      *u = fmod(x * Image->width, (double)Image->width); //After
Same file, line 973
      *v = fmod(x * Image->height, Image->height); //Before
      *v = fmod(x * Image->height, (double)Image->height); //After
Same file, line 986
      *u = fmod(y * Image->width, Image->width); //Before
      *u = fmod(y * Image->width, (double)Image->width); //After
Same file, line 990
      *v = fmod(y * Image->height, Image->height); //Before
      *v = fmod(y * Image->height, (double)Image->height); //After
Same file, line 1003
      *u = fmod(z * Image->width, Image->width); //Before
      *u = fmod(z * Image->width, (double)Image->width); //After
Same file, line 1007
      *v = fmod(z * Image->height, Image->height); //Before
      *v = fmod(z * Image->height, (double)Image->height); //After

"POV-RAY Core\pattern.cpp", line 242
   value = pow(value, TPat->Exponent); //Before
   value = pow(value, (double)TPat->Exponent); //After

"POV-Ray Core\lighting.cpp", line 1933
    Intensity = pow(fabs(Cos_Angle_Of_Incidence), Finish->Brilliance); 
//Before
    Intensity = pow(fabs(Cos_Angle_Of_Incidence), 
(double)Finish->Brilliance); //After
Same file, line 2112
    Intensity = Finish->Phong * pow(Cos_Angle_Of_Incidence, 
Finish->Phong_Size); //Before
    Intensity = Finish->Phong * pow(Cos_Angle_Of_Incidence, 
(double)Finish->Phong_Size); //After
Same file, line 2209
      Intensity = Finish->Specular * pow(Cos_Angle_Of_Incidence, 
Finish->Roughness); //Before
      Intensity = Finish->Specular * pow(Cos_Angle_Of_Incidence, 
(double)Finish->Roughness); //After
Same file, line 4110
          Att = 1.0 + pow(Intersect->Depth / Interior->Fade_Distance, 
Interior->Fade_Power); //Before
          Att = 1.0 + pow(Intersect->Depth / Interior->Fade_Distance, 
(double)Interior->Fade_Power); //After
Same file, line 4400
          k = 1.0 + pow(Ray_Intersection->Depth / 
Interior->Fade_Distance, Interior->Fade_Power); //Before
          k = 1.0 + pow(Ray_Intersection->Depth / 
Interior->Fade_Distance, (double)Interior->Fade_Power); //After
Same file, line 4747
          Att = 1.0 + pow(Intersection->Depth / 
Interior->Fade_Distance, Interior->Fade_Power); //Before
          Att = 1.0 + pow(Intersection->Depth / 
Interior->Fade_Distance, (double)Interior->Fade_Power); //After

"POV-Ray Core\colutils.cpp", line 121
    Colour[pTRANSM]  = 1.0 - pow((1.0 - Colour[pTRANSM]), 
opts.GammaFactor); //Before
    Colour[pTRANSM]  = 1.0 - pow((1.0 - Colour[pTRANSM]), 
(double)opts.GammaFactor); //After

"POV-Ray Core\photons.cpp", line 892
    photonOptions.photonSpread *= 
sqrt(Light->Area_Size1*Light->Area_Size2); //Before
    photonOptions.photonSpread *= 
sqrt((float)(Light->Area_Size1*Light->Area_Size2)); //After

"POV-Ray Core\fnintern.cpp", line 349 (Don't ask me what this code 
does...)
  12*r2*PARAM_Z*(27*ph*ph-24*z2*ph+ 
36*sqrt(2)*PARAM_Y*PARAM_Z*(y2-3*x2)+4*z2*z2)+ //Before
  12*r2*PARAM_Z*(27*ph*ph-24*z2*ph+ 
36*sqrt((float)2)*PARAM_Y*PARAM_Z*(y2-3*x2)+4*z2*z2)+ //After
Same file, line 351
  108*sqrt(2)*PARAM_X*PARAM_Z*(x2-3*y2)+4*z2*z2) ); //Before
  108*sqrt((float)2)*PARAM_X*PARAM_Z*(x2-3*y2)+4*z2*z2) ); //After
Same file, line 585
  x1=fabs(fmod(fabs(PARAM_X), sqrt(3))-sqrt(3)/2); //Before
  x1=fabs(fmod(fabs(PARAM_X), sqrt(3.0))-sqrt(3.0)/2); //After
Same file, line 587
  x2=sqrt(3)/2-x1; //Before
  x2=sqrt(3.0)/2-x1; //After
Same file, line 609
  x1=fabs(fmod(fabs(PARAM_X), sqrt(3))-sqrt(3)/2); //Before
  x1=fabs(fmod(fabs(PARAM_X), sqrt(3.0))-sqrt(3.0)/2); //After
Same file, line 611
  x2=sqrt(3)/2-x1; //Before
  x2=sqrt(3.0)/2-x1; //After

If you have made all of the above changes correctly, then you'll have 
POV-Ray 3.5 building in VS.NET 2003!

Now that you've reached this point, the next logical step is to put all 
of Microsoft's new compiler optimizations to work.

-Switch your project into the "Release" configuration.
-Go to Project->povray Properties.
-From this initial screen, change "Whole Program Optimization" to "Yes".
-Open the "C\C++" folder.
-Choose "Optimization" from the expanded items list.  Make the following 
changes:
--Global Optimization: Yes
--Inline Function Expansion: Any Suitable
--Enable Intrinsic Functions: Yes
--Favor Size or Speed: Favor Fast Code
--Omit Frame Pointers: Yes
--Optimize for Processor: (Think about this before deciding) Pentium 4 
and Above.
--Optimize for Windows Application: Yes
-Go to the "Code Generation" item.  Make these changes:
--Enable String Pooling: Yes
--Buffer Security Check: No
--Enable Enhanced Instruction Set: (Think about this before deciding) 
Streaming SIMD Extensions 2
--Go to the Precompiled Header item.  Change "Create/Use Precompiled 
Header" to "Not Using Precompiled Headers".
-Expand the "Linker" item list.
--Go to the "Optimization" item, and (think before doing) change 
"Optimize for Windows 98" to "No".

The last step is to build your VS.NET 2003 fully-optimized POV-Ray 3.5.  
Because of all the optimizations, the build will take longer than 
before.

In the solution explorer, right-click the "povray" project and choose 
"Set as Startup Project".  Press Control+F5 to run it.  Use your 
personalized copy to run "%official povray install 
folder%\scenes\advanced\benchmark.pov" and compare it with the official 
release.  The speed is quite good... on my machine (P4 2.26, 512MB, 
WinXP), my custom build did it (using recommended command-line options) 
in slightly -less- time than the official POV-Ray :)

None of the source code changes in this document should break POV 
functionality in any way, so it should be safe to merge them into the 
main source tree.

If I'm still around when POV-Ray 3.6 is released and it's still not 
VS.NET 2003 compatible, I'll update this document.

-Ryan


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.